package org.phalanx.client.mapeditor;

import java.awt.Color;
import java.awt.FlowLayout;

import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class PhalanxMapNameInfoPanel extends JPanel {
	private static final long serialVersionUID = -4798707235719607363L;
	private JTextField mapName;
	private JTextField mapVersion;

	public PhalanxMapNameInfoPanel() {
		initializePanel();
		setUpComponents();
		setUpPanels();
	}
	
	private void initializePanel() {
		this.setBackground(Color.black);
		this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
	}
	
	private void setUpComponents() {
		mapName = new JTextField();
		mapName.setColumns(10);
		
		mapVersion = new JTextField();
		mapVersion.setColumns(4);
	}
	
	private void setUpPanels() {
		JPanel p = getPanel();
		
		p.setLayout(new FlowLayout(FlowLayout.LEFT));
		p.add(getJLabel("Map Name: "));
		p.add(mapName);
		
		this.add(p);
		
		p = getPanel();
		p.setLayout(new FlowLayout(FlowLayout.LEFT));
		p.add(getJLabel("Map Version: "));
		p.add(mapVersion);
		
		this.add(p);
	}
	
	private JPanel getPanel() {
		JPanel p = new JPanel();
		p.setBackground(Color.black);
		
		return p;
	}
	
	private JLabel getJLabel(String text) {
		JLabel temp = new JLabel();
		temp.setForeground(Color.white);
		temp.setText(text);

		return temp;
	}

	public JTextField getMapName() {
		return mapName;
	}

	public JTextField getMapVersion() {
		return mapVersion;
	}
	
	public void setMapName(String name) {
		mapName.setText(name != null ? name : "");
	}
	
	public void setMapVersion(String ver) {
		mapVersion.setText(ver != null ? ver : "");
	}
}
